on_action = {
    on_game_start = {
        effect = {
            # Performance optimizations for CK3: applies long-term modifiers
            every_player = {
                add_character_modifier = {
                    modifier = performance_mode_modifier
                    days = -1
                }
            }
        }
    }

    on_yearly_pulse = {
        effect = {
            if = {
                limit = {
                    is_ai = yes
                    is_alive = yes
                }
                random = {
                    chance = 10
                    trigger_event = { id = perf_patch.1 }
                }
            }
        }
    }

    on_five_year_pulse = {
        random_events = {
            100 = nothing
            10 = perf_cull.1     # Character culling
            10 = perf_debug.1    # Log culling actions
            50 = perf_cull.2     # AI plot throttling
        }
    }

    on_birth = {
        effect = {
            if = {
                limit = {
                    mother = {
                        is_ai = yes
                        num_of_living_children >= 10
                        NOT = { has_trait = trait_intellect_good_3 }
                        NOT = { has_trait = fertile }
                    }
                }
                mother = {
                    set_fertility = 0
                }
            }
        }
    }
}


Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.


Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character

Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.

Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.

Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.

Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.

Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    trigger = { }

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.

By addressing these syntax errors and adding the missing localization entries, your Crusader Kings 3 mod should function correctly and display text properly within the game.

Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {


Suggested Fixes:
Okay, I will provide detailed instructions to fix the syntax errors and missing localization entries in your Crusader Kings 3 mod. I will address each error by file, including file locations and formats.

**1. Syntax Errors in Event Files**

CK3 event files use a specific syntax that needs to be followed strictly. Common errors include missing brackets, incorrect variable usage, and invalid scopes.

*   **File:** `Crusader Kings 3 Performance/events/performance_debug.txt`
    *   **Error:** Unmatched closing bracket `}`.
    *   **Fix:** Remove the extra closing bracket `}`. Ensure that the code block's logic is complete before closing.

Corrected file:

```
namespace = perf_debug

# 🧪 Debug: Log all characters with cull flag
character_event = {
    id = perf_debug.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_living_character = {
            limit = {
                has_character_flag = culled_recently
            }

            log = "[GetDate] DEBUG: [ROOT.GetName] (ID: [ROOT.GetID]) was previously culled."
        }
    }
}

# 🧪 Debug: Count characters culled
character_event = {
    id = perf_debug.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        set_variable = { name = total_culled_characters value = 0 }

        every_living_character = {
            limit = { has_character_flag = culled_recently }
            change_variable = { which = total_culled_characters value = 1 }
        }

        log = "[GetDate] DEBUG: Total culled characters with flag: [GetVariable:total_culled_characters]"
    }
}
```

*   **File:** `Crusader Kings 3 Performance/events/performance_patch_events.txt`
    *   **Error:** The namespace is defined twice.
    *   **Fix**: Remove the second namespace.

```
namespace = perf_patch

# 🔁 Monthly AI courtier cleanup
event = {
    id = perf_patch.1
    type = character_event
    hidden = yes
    is_triggered_only = yes

    trigger = {
        is_ai = yes
        has_court = yes
    }

    immediate = {
        every_courtier = {
            limit = {
                is_alive = yes
                NOT = { has_landed_title = yes }
                age >= 40
                NOT = { has_trait = trait_intellect_good_3 }
                NOT = { has_trait = trait_intellect_good_2 }
                NOT = { has_trait = trait_intellect_good_1 }
                NOT = { has_trait = trait_strong }
                NOT = { has_trait = hero }
                NOT = { has_any_court_position = yes }
                NOT = { is_involved_in_any_plot = yes }
                num_of_living_children >= 5
            }

            death = {
                death_reason = death_natural_causes
            }
        }
    }
}

# 🧹 Global scripted culling for low-value characters
event = {
    id = perf_cull.1
    hide_window = yes
    is_triggered_only = yes

    immediate = {
       every_character = {
            limit = { performance_should_cull_character = yes }

            log = "[GetDate] Culled character: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = culled_recently
            remove_character = yes
        }
    }
}

# 🤐 AI Plot Throttling
event = {
    id = perf_cull.2
    hide_window = yes
    is_triggered_only = yes

    immediate = {
        every_character = {
            limit = { performance_should_throttle_ai_plots = yes }

            log = "[GetDate] Throttled AI plotting: [ROOT.GetName] (ID: [ROOT.GetID])"
            set_character_flag = ai_plot_throttled_recently
            remove_all_schemes = yes
        }
    }
}
```

**2. Missing Localization Entries**

Localization is how the game displays text to the user. If a text key is used in the code but not defined in a localization file, the key itself will appear in the game, like `increased_savings_desc`.

*   **File:** `Crusader Kings 3 Performance/common/character_modifiers/increased_savings.txt`
    *   **Missing Localization:**
        *   `name = increased_savings`
        *   `description = increased_savings_desc`

    *   **Fix:** Add these keys to a localization file.

        1.  **File Location:** Create a new file (if one doesn't exist) or add to an existing file under `Crusader Kings 3 Performance/common/localization/english/`. A good name for it would be `performance_modifiers_l_english.yml`.
        2.  **File Format (YAML):**

```yaml
l_english:
 increased_savings: "Increased Savings" # The name of the modifier
 increased_savings_desc: "This character is saving more money each month." # The modifier's description
```

*   **Note**: if you have more than one localization file, make sure that the keys are unique. Also, be sure to save the file with UTF-8 encoding.


**3. Typos, formatting and other issues:**
*   **File:** `Crusader Kings 3 Performance/common/traits/00_traits.txt`

There are extra newlines in the file.

Corrected file:

```
trait_performance_optimized = {
    name = trait_performance_optimized
    icon = "gfx/interface/icons/traits/trait_dull.dds"
    desc = trait_performance_optimized_desc
   
    cost = 0
    inherit_chance = 0
   
    is_good = no
    is_bad = yes
    visible = no # Hidden from UI
   
    character_modifier = {
    fertility = -0.2 #Reduced fertility
    monthly_character_prestige = -0.1 # Reduced prestige gain
    attraction_opinion = -5 # Lowered attraction opinion
    }
   }
```

*   **File:** `Crusader Kings 3 Performance/common/on_action/scripted_effects/performance_effects.txt`

All the contents of the file are repeated, resulting in repeated definitions.

Corrected file:

```
performance_toggle_effect = {
# Reusable effect (can be called in decisions, events, etc.)
            add_character_modifier = {
                modifier = performance_mode_modifier
                duration = -1
}
}

performance_mode_modifier = {
# Modifier applied in performance mode
            monthly_character_prestige = -0.1
            fertility = -0.2
            attraction_opinion = -5
}
```

**4. General Tips**

*   **Validation:** Always validate your files using a CK3 validator tool or by running the game in debug mode to catch errors early.
*   **Consistency:** Keep your file structure and naming conventions consistent to avoid confusion.
*   **Comments:** Use comments (`#`) liberally to explain your code. This helps you and others understand the purpose of each section.
*   **Mod Loading Order:** Sometimes, conflicts arise from mod loading order. Ensure your mod loads correctly by adjusting its position in the playset.